package com.fox0g.mapper;



import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fox0g.pojo.Farm;
import com.fox0g.pojo.Freshfood;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 00000
 * @description 针对表【farm】的数据库操作Mapper
 * @createDate 2023-08-01 14:42:53
 * @Entity com.fox0g.pojo.Freshfood
 */

@Mapper
public interface FreshfoodMapper extends BaseMapper<Freshfood> {


    @Results({
            @Result(column = "vid", property = "vid"),
            @Result(column = "pid", property = "pid"),
            @Result(column = "tin", property = "tin"),
            @Result(column = "tout", property = "tout"),
            @Result(column = "lxin", property = "lxin"),
            @Result(column = "alarm", property = "alarm"),
            @Result(column = "create_time", property = "create_time")
    })

    @Insert("insert into farm.farmdata(vid,pid,tin,tout,lxin,alarm,create_time)" +
            " values (#{vid},#{pid},#{tin},#{tout},#{lxin},#{alarm},#{createTime})")
    int insert(Freshfood freshfood) ;


    @Select("select vid,pid,tin,tout,lxin,alarm,create_time from farm.farmdata")
    List<Freshfood> allData();

    List<Freshfood> selectbydate(@Param("begin") String begin, @Param("end") String end);

    @Results({
            @Result(column = "pid", property = "pid"),

    })
    @Select("select pid from farmdata where id = #{id}")
    Freshfood select1(@Param("id") Integer id);

    @Select("select max(farm.farmdata.id) from farmdata")
    Integer selectID();

    @Select("select * from farmdata where farmdata.id = #{id}")
    Freshfood select(@Param("id") Integer id);


//    List<Freshfood> getByTime(String begin, String end);
}
